//
//  FBDevicesList.m
//  EquesCat
//
//  Created by Chun Hung Cheung on 2024/12/17.
//

#import "FBDevicesList.h"
#import "Tooles.h"
@implementation FBDevicesList


+ (id)FBDevicesListWithdict:(NSDictionary *)dict
{
    return [[self alloc] initWithdict:dict];
}

- (id)initWithdict:(NSDictionary *)dict andonlines:(NSDictionary *)dict2
{
    if (self = [super init]) {
        self.bg_tableName = @"FBDevicesList";
        self.bid  = [dict objectForKey:@"bid"];
        self.name = [dict objectForKey:@"name"];
       
        if ([[dict objectForKey:@"appId"] intValue] > 0) {
            self.role = [[dict objectForKey:@"appId"] intValue];
        }else{
            self.role = [[dict objectForKey:@"role"] intValue];
        }
        self.device_class = [[dict objectForKey:@"device_class"] intValue];
        if ([dict objectForKey:@"nick"]) {
            self.nick = [dict objectForKey:@"nick"];
        }else{
            self.defaultNick = [dict objectForKey:@"defaultNick"];
        }
        self.default_rollover_day = [[dict objectForKey:@"default_rollover_day"] intValue];
        self.is_share = [[dict objectForKey:@"is_share"] intValue];
        self.capability = [dict objectForKey:@"capability"];
        self.userName = [Tooles getuserToken];
        if ((dict2) && [dict2 count] != 0)
        {
            self.remoteupg = [[dict2 objectForKey:@"remoteupg"] intValue];
            self.status = [[dict2 objectForKey:@"stat"] intValue];
        }else{
            self.status = 0;
        }
    
        if([dict objectForKey:@"intercom"]){
            self.intercom = [[dict objectForKey:@"intercom"] intValue];
        }
        if([dict objectForKey:@"speech"]){
            self.speech = [[dict objectForKey:@"speech"] intValue];
        }
        
        if([self.capability objectForKey:@"control"]){
            self.control = [[self.capability objectForKey:@"control"] intValue];
        }
    
    }
    
    return self;
}



- (id)initWithdict:(NSDictionary *)dict
{
    if (self = [super init]) {
        self.bg_tableName = @"FBDevicesList";
        self.bid = [dict objectForKey:@"bid"];
        self.name = [dict objectForKey:@"name"];
        if ([[dict objectForKey:@"appId"] intValue] > 0) {
            self.role = [[dict objectForKey:@"appId"] intValue];
        }else{
            self.role = [[dict objectForKey:@"role"] intValue];
        }
        self.device_class = [[dict objectForKey:@"device_class"] intValue];
        if ([dict objectForKey:@"nick"]) {
            self.nick = [dict objectForKey:@"nick"];
        }else{
            self.defaultNick = [dict objectForKey:@"defaultNick"];
        }
        NSDictionary *dic = [dict objectForKey:@"capability"];
        self.default_rollover_day = [[dic objectForKey:@"default_rollover_day"] intValue];
        self.is_share = [[dict objectForKey:@"is_share"] intValue];
        self.capability = [dict objectForKey:@"capability"];
        self.speech = [[dict objectForKey:@"speech"] intValue];
        if([dict objectForKey:@"intercom"]){
            self.intercom = [[dict objectForKey:@"intercom"] intValue];
        }
        if([dict objectForKey:@"speech"]){
            self.speech = [[dict objectForKey:@"speech"] intValue];
        }
        self.userName = [Tooles getuserToken];
    }
    return self;
   
}




@end
